class Solution 
{
public:
    vector<int> twoSum(vector<int>& price, int target) 
    {
        int left = 0, right = price.size() - 1;

        // vector<int> ans;
        while(left < right)
        {
            int sum = price[left] + price[right];
            
            if(sum < target) ++left;
            else if(sum > target) --right;
            else
            {
                //ans.push_back(price[left]);
                //ans.push_back(price[right]);

                break;
            }
        }

        //return ans;
        return {price[left], price[right]};
    }
};